package livedata

import androidx.lifecycle.MutableLiveData

/**
 * 静态的需要注意，程序不结束，不会被销毁
 */
class GlobalLiveData private constructor() : MutableLiveData<String>() {

  companion object SingleTon {
    private var instance: GlobalLiveData? = null

    fun getInstance(): GlobalLiveData {
      if (instance == null) {
        instance = GlobalLiveData()
      }
      return instance as GlobalLiveData
    }

    /**
     * 销毁
     */
    fun destroy() {
      instance = null
    }
  }

}